home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 201 / 201.xpi / modules / version.jsm < prev   
Text File  |  2010-01-11  |  700b  |  21 lines

  1. const EXPORTED_SYMBOLS = ['ID', 'ITEM', 'VERSION', 'BASE_VERSION', 'NAME', 'compareVersion'];
  2.  
  3. const ID = '{DDC359D1-844A-42a7-9AA1-88A850A938A8}';
  4. const ITEM = Components.classes["@mozilla.org/extensions/manager;1"]
  5.     .getService(Components.interfaces.nsIExtensionManager)
  6.     .getItemForID(ID);
  7.  
  8. const VERSION = ITEM.version;
  9. const BASE_VERSION = VERSION.replace(/^([\d\w]+\.[\d\w]+).*?$/, '$1');
  10. const NAME = ITEM.name;
  11.  
  12. const comparator = 
  13.     Components.classes['@mozilla.org/xpcom/version-comparator;1']
  14.     .getService(Components.interfaces.nsIVersionComparator);
  15.  
  16. function compareVersion(version, cmp) {
  17.     if (!cmp) {
  18.         [version, cmp] = [VERSION, version];
  19.     }
  20.     return comparator.compare(version, cmp);
  21. }